package org.sunshinebox.team.sweettest;

import java.lang.reflect.Field;
import java.util.List;

import org.sunshinebox.team.sweettest.definition.Mocked;
import org.sunshinebox.team.sweettest.easymock.EasyMockTools;

public abstract class Tools {
	
	InstanceManipulator instanceManipulator;
	
	public static Tools createForObject(Object test) {
		return createWithManipulator(new DefaultInstanceManipulator(test));
	}
	
	public static Tools createWithManipulator(InstanceManipulator manipulator) {
		Tools instance = new EasyMockTools();
		instance.setInstanceManipulator(manipulator);
		return instance;
	}
	
	private void setInstanceManipulator(InstanceManipulator instanceManipulator) {
		this.instanceManipulator = instanceManipulator;
	}
	
	
	public abstract void setup();
	public abstract void arm();
	public abstract void verify();

	protected List<Field> getMockedFields() {
		return instanceManipulator.getFieldAnnotatedWith(Mocked.class);
	}

	
	protected void setFieldValue(Field field, Object value) {
		instanceManipulator.setFieldValue(field, value);
	}

	protected Object getFieldValue(Field field) {
		return instanceManipulator.getFieldValue(field);
	}

	

}
